part of 'alert.dart';

///预设选择
class AlertPreset extends StatelessWidget {
  final void Function(int i, String title)? onPressed;
  const AlertPreset({Key? key, this.onPressed}) : super(key: key);

  static final kPresetTitles = [
    'POP',
    'Dance',
    'Rock',
    'Classic',
    'Vocal',
    'Bass',
  ];

  @override
  Widget build(BuildContext context) {
    return UnconstrainedBox(
        child: Material(
      color: Colors.transparent,
      child: Container(
        width: 172,
        height: 250,
        decoration: kAlertBoxDecoration,
        clipBehavior: Clip.hardEdge,
        child: Column(
          children: [
            Container(
              alignment: Alignment.center,
              height: 50,
              child: Text(
                'Preset EQ',
                style: TextStyle(fontSize: 20, color: Colors.white),
              ),
            ),
            //列表
            ...kPresetTitles.map((e) {
              final isLast = e == kPresetTitles.last;
              final i = kPresetTitles.indexOf(e);
              return Flexible(
                child: GestureDetector(
                  onTap: () {
                    onPressed?.call(i, e);
                    Get.back();
                  },
                  child: Container(
                    decoration: BoxDecoration(
                      border: isLast ? null : Border(bottom: BorderSide()),
                      color: Colors.white,
                    ),
                    alignment: Alignment.center,
                    width: double.infinity,
                    child: Text(
                      e,
                      style: TextStyle(color: Colors.black),
                    ),
                  ),
                ),
              );
            }).toList(),
          ],
        ),
      ),
    ));
  }
}
